/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ecom.client;

/**
 *
 * @author DE SILVA
 */

import ecom.beans.EcomAdminRemote;
import ecom.beans.EcomCustomerRemote;
import javax.transaction.*;
import javax.naming.InitialContext;

public class InitDataBase {

    public static void initDatabase(InitialContext ic, UserTransaction utx, EcomAdminRemote ecomAdminBean, EcomCustomerRemote ecomcustomerBean) {

        try {
            System.out.println("Initializing database...");

            utx.begin();

            ecomcustomerBean.buyCart();

            ecomcustomerBean.setUser(null);
            utx.commit();
        } catch (Exception e) {
            System.err.println("InitDataBase program get an exception " + e);
            System.exit(2);
        }
    }
}
